<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
	<style type="text/css">
    html,body
    {
        padding:0;
        margin:0;
        border:0;     
        width:100%;
        height:100%;
        overflow:hidden;   
    }
    </style>
</head>
<body>
	<div class="mini-toolbar" style="text-align:center;line-height:30px;" 
        borderStyle="border-left:0;border-top:0;border-right:0;">
          <label >名称：</label>
          <input id="key" class="mini-textbox" style="width:150px;" onenter="onKeyEnter"/>
          <a class="mini-button" style="width:60px;" onclick="search()">查询</a>
    </div>
    <div class="mini-fit">
        <ul id="tree1" class="mini-tree" url="call_health_view.do" style="width:100%;height:100%;" 
   		showTreeIcon="true" textField="name" idField="id" parentField="pid" onnodedblclick="onNodeDblClick" resultAsTree="false"expandOnLoad="true" showTreeLines="true"> 
		</ul>
    </div>                
    <div class="mini-toolbar" style="text-align:center;padding-top:8px;padding-bottom:8px;" 
        borderStyle="border-left:0;border-bottom:0;border-right:0;">
        <a class="mini-button" style="width:60px;" onclick="onOk()">确定</a>
        <span style="display:inline-block;width:25px;"></span>
        <a class="mini-button" style="width:60px;" onclick="onCancel()">取消</a>
    </div>
</body>
</html>

<script type="text/javascript">
	mini.parse();
	
	var tree = mini.get("tree1");
	
	function GetData() {
	    var node = tree.getSelectedNode();
	    return node;
	}
	function search() {
	    var key = mini.get("key").getValue();
	    if(key == ""){
	        tree.clearFilter();
	    }else{
	        key = key.toLowerCase();
	        tree.filter(function (node) {
	            var text = node.name ? node.name.toLowerCase() : "";
	            if (text.indexOf(key) != -1) {
	                return true;
	            }
	        });
	    }
	}
	function onKeyEnter(e) {
	    search();
	}
	function onNodeDblClick(e) {
	    onOk();
	}
	//////////////////////////////////
	function CloseWindow(action) {
	    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
	    else window.close();
	}
	
	function onOk() {
	    var node = tree.getSelectedNode();
	    if (node && node.pid == "0") {
	    	mini.alert("请选择具体子类别！");
	    	return;
	    }else if(null == node){
	        mini.alert("请选择一个类别！");
	        return;
	    }
	
	    CloseWindow("ok");        
	}
	function onCancel() {
	    CloseWindow("cancel");
	}

</script>